{% extends "blog/base.html" %}

{% block blog_content %}
<div class="row">
    <div class="col-md-8">
        <h3>All Blog Posts</h3>
        
        {% if posts %}
            {% for post in posts %}
                <div class="card mb-3">
                    <div class="card-header">
                        <h5>{{ post.title }}</h5>
                        <small class="text-muted">
                            By {{ post.author }} on {{ post.date }}
                        </small>
                    </div>
                    <div class="card-body">
                        <p class="card-text">{{ post.excerpt }}</p>
                        <a href="{{ url_for('blog.post', post_id=loop.index) }}" class="btn btn-primary">Read More</a>
                    </div>
                </div>
            {% endfor %}
        {% else %}
            <div class="alert alert-info">
                <p>No blog posts available yet.</p>
                <a href="{{ url_for('blog.create') }}" class="btn btn-primary">Create the First Post</a>
            </div>
        {% endif %}
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5>Blog Statistics</h5>
            </div>
            <div class="card-body">
                <p><strong>Total Posts:</strong> {{ posts|length }}</p>
                <p><strong>Categories:</strong> 5</p>
                <p><strong>Authors:</strong> 3</p>
            </div>
        </div>
        
        <div class="card mt-3">
            <div class="card-header">
                <h5>Recent Posts</h5>
            </div>
            <div class="card-body">
                <ul>
                    {% for post in posts[:3] %}
                        <li><a href="{{ url_for('blog.post', post_id=loop.index) }}">{{ post.title }}</a></li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}